package com.hxht.cmp.controller;


import com.hxht.cmp.common.Constants;
import com.hxht.cmp.common.enums.ResultCode;
import com.hxht.cmp.common.result.ResultResponse;
import com.hxht.cmp.pojo.CourtroomEx;
import com.hxht.cmp.service.CourtRoomService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/courtRoom")
public class CourtRoomController {
    private final Logger logger = LoggerFactory.getLogger(CourtRoomController.class);

    @RequestMapping("getCfgInfo")
    public ResultResponse getCfgInfo(String courtRoomUid) {
        if (StringUtils.isBlank(courtRoomUid)) {
            return ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        CourtroomEx courtroomEx = Constants.COURTROOM_MAP.get(courtRoomUid);
        logger.info("根据courtRoomUid查询CFG信息：" + courtroomEx.getConfigs());
        if (ObjectUtils.isEmpty(courtroomEx) || ObjectUtils.isEmpty(courtroomEx.getConfigs())) {
            return ResultResponse.failed(ResultCode.SEARCH_NULL);
        }
        return ResultResponse.success(courtroomEx.getConfigs());
    }


}
